home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Applications / Moscow ML 1.31 / source code / mosml / src / mosmllib / General.fke < prev    next >
Encoding:
Text File  |  1996-07-03  |  3.2 KB  |  111 lines  |  [TEXT/R*ch]

  1. (* General -- SML Standard Library *)
  2.  
  3. eqtype char
  4. type   exn
  5. eqtype int
  6. eqtype real
  7. eqtype string
  8. eqtype unit
  9.  
  10. datatype bool      = false | true
  11. datatype 'a list   = nil | op :: of 'a * 'a list
  12. datatype 'a option = NONE | SOME of 'a
  13. datatype ordering  = LESS | EQUAL | GREATER
  14. datatype '_a ref   = ref of '_a 
  15.  
  16. exception Bind
  17. exception Match
  18. exception Interrupt
  19.  
  20. exception Subscript
  21. exception Size
  22. exception Fail of string
  23.  
  24. exception Overflow
  25. exception Div
  26. exception Sqrt
  27. exception Ln
  28. exception Trig
  29.  
  30. val exnName : exn -> string
  31. val exnMessage : exn -> string
  32.  
  33. exception Option
  34. val getOpt : 'a option * 'a -> 'a
  35. val isSome : 'a option -> bool
  36. val valOf  : 'a option -> 'a
  37.  
  38. val not : bool -> bool
  39.  
  40. (* Below, cirs is char, int, string, or real:                   *)
  41. val <      : cirs * cirs -> bool
  42. val <=     : cirs * cirs -> bool
  43. val >      : cirs * cirs -> bool
  44. val >=     : cirs * cirs -> bool
  45. val =      : ''a * ''a -> bool
  46. val <>     : ''a * ''a -> bool
  47.  
  48. (* Below, num is int or real:                                   *)
  49. val ~      : num -> num            (* raises Overflow      *)
  50. val +      : num * num -> num        (* raises Overflow      *)
  51. val -      : num * num -> num        (* raises Overflow      *)
  52. val *      : num * num -> num        (* raises Overflow      *)
  53. val /      : real * real -> real    (* raises Div, Overflow *)
  54. val div    : int * int -> int        (* raises Div, Overflow *)
  55. val mod    : int * int -> int        (* raises Div           *)
  56. val quot   : int * int -> int
  57. val rem    : int * int -> int        (* raises Div           *)
  58.  
  59. val floor  : real -> int        (* raises Overflow      *)
  60. val real   : int -> real
  61.  
  62. val sqrt   : real -> real        (* raises Sqrt          *)
  63. val ln     : real -> real        (* raises Ln            *)
  64. val exp    : real -> real        (* raises Overflow      *)
  65. val sin    : real -> real        (* raises Fail          *)
  66. val cos    : real -> real        (* raises Fail          *)
  67. val arctan : real -> real
  68.  
  69. val size   : string -> int
  70. val ^      : string * string -> string    (* raises Size          *)
  71.  
  72. val o      : ('b -> 'c) * ('a -> 'b) -> ('a -> 'c)
  73. val ignore : 'a -> unit
  74. val before : 'a * unit -> 'a
  75.  
  76. val !   : 'a ref -> 'a
  77. val :=  : 'a ref * 'a -> unit
  78.  
  79. (* Non-standard types and exceptions *)
  80.  
  81. datatype 'a frag = QUOTE of string | ANTIQUOTE of 'a
  82.  
  83. exception Io of string
  84. exception Graphic_failure of string
  85. exception Out_of_memory
  86.  
  87. (* 
  88.  
  89.    [exnName exn] returns the name of the exception constructor in exn,
  90.    if possible; otherwise returns the string "<unknown>".  Works at
  91.    least for the exceptions defined by the SML Standard Library.
  92.    Never raises an exception itself.  The name returned may be that of
  93.    any exception constructor aliasing with exn.  For instance,
  94.     (exception E1; exception E2 = E1; exnName E2)
  95.    may evaluate to "E1" or "E2".
  96.  
  97.    [exnMessage exn] formats and returns a message corresponding to
  98.    exception exn, if possible; otherwise returns the string "Uncaught
  99.    exception: <unknown>".  Works at least for the exceptions defined
  100.    by the SML Standard Library.  Never raises an exception itself.
  101.    The name returned may be that name of any exception aliasing with
  102.    exn.
  103.  
  104.    [getOpt(opt, a)] returns v if opt is SOME v; otherwise returns a.
  105.    
  106.    [isSome opt] returns true if opt is SOME v; otherwise returns false.
  107.    
  108.    [valOf opt] returns v if opt is SOME v; otherwise raises Option.
  109.  
  110. *)
  111.